import wepy from 'wepy';

export default class extends wepy.mixin {
    components = {};

    data = {
        // 轮播图
        mSwipperList: [],
        // 分类列表
        mCategoryList: [],
        mFloorList: []
    };
    async fetchSwipperData() {
        const { meta, message } = (await wepy.get('/home/swiperdata')).data;
        console.log(message);
        if (meta.status !== 200) return wepy.baseToast();
        this.mSwipperList = message;
        // 提示刷新
        this.$apply();
    }

    async fetchCategoryData() {
        const { meta, message } = (await wepy.get('/home/catitems')).data;
        if (meta.status !== 200) return wepy.baseToast();
        this.mCategoryList = message;
        // 提示刷新
        this.$apply();
    }

    async fetchFloorData() {
        const { meta, message } = (await wepy.get('/home/floordata')).data;
        console.log(message);

        if (meta.status !== 200) return wepy.baseToast();
        this.mFloorList = message;
        // 提示刷新
        this.$apply();
    }
    computed = {};

    methods = {
        // 点击楼层中的item跳转页面
        goProductList(url) {
            console.log("dddddddddddddd");

            console.log(url);

            // wepy.navigateTo({
            //     url
            // });
        }
    };

    events = {};

    onLoad() {
        this.fetchSwipperData();
        this.fetchCategoryData();
        this.fetchFloorData();
    }
}